﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Shake.Framework.View;
using Shake.Framework.Attributes;
using Shake.Framework.Repository;
using Shake.Domain.Models;
using Shake.Business.Infrastructures;
using Shake.Framework.Models;
using Shake.Framework.Context;

namespace Shake.Web.Controllers
{
    [Theme("LayUiAdmin")]
    public class FlightController : Controller
    {
        public IFlightService FlightService { get; set; }

        public ActionResult Index(PageArgument pageArg)
        {
            var results = FlightService.GetFlights(pageArg);
            return this.ToJson(results);
        }

        public ActionResult Create(List<FlightTx> flight)
        {
            if (flight == null || flight.Count == 0) return this.PostResult(new PostResult(false));
            FlightService.Create(flight);
            return this.PostResult(new PostResult() { Data = flight });
        }

        public ActionResult Remove(List<FlightTx> flight)
        {
            if (flight == null || flight.Count == 0) return this.PostResult(new PostResult(false));
            FlightService.Remove(flight);
            return this.PostResult(new PostResult() { Data = flight });
        }

        public ActionResult Update(List<FlightTx> flight)
        {
            if (flight == null || flight.Count == 0) return this.PostResult(new PostResult(false));
            FlightService.Update(flight);
            return this.PostResult(new PostResult() { Data = flight });
        }
    }
}
